// 封装请求方法
import axios from "./axios";

const instance = axios();
export default {
  get(url, params, headers, request = true,down,downUrl) {
    const options = {};
    if (params) {
      options.params = params;
    }
    if (headers) {
      options.headers = headers;
    }
    //下载文件流
    if (down) {
      options.responseType = down;
      options.downUrl = downUrl;
    }

    options.request = request;
    return instance.get(url, options);
  },
  post(url, data, headers, params) {
    const options = {};
    if (headers) {
      options.headers = headers;
    }
    if (params) {
      options.params = params;
    }

    return instance.post(url, data, options);
  },
  put(url, params, headers) {
    const options = {};
    if (headers) {
      options.headers = headers;
    }
    return instance.put(url, params, options);
  },
  delete(url, params, headers) {
    const options = {};
    if (params) {
      options.params = params;
    }
    if (headers) {
      options.headers = headers;
    }
    return instance.delete(url, options);
  }
};
